#ifndef GAMEENGINE_GRAPHICS_GRAPHIC_RESOURCE_H
#define GAMEENGINE_GRAPHICS_GRAPHIC_RESOURCE_H

#include <GameEngine/Graphics/graphics_settings.h>
#include <GameEngine/Graphics/openGL.h>
#include <GameEngine/Core/Resource/resource.h>
#include <GameEngine/Core/Classes/rtti.h>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif



//========================================================



//! Methods for graphic resources
/*!
 *  A resource is an entity that can be shared by several
 *  objects. It provides mechanisms to reference/unreference
 *  its users. When a resource does not have any user any
 *  more, it is destroyed for good.
 */
class _Graphics_decl GraphicResource {
	GAMEENGINE_DECLARE_RTTI_SINGLE(GraphicResource)

protected:
	//! Typedef to handle IDs associated to graphic ressources
	typedef GLuint ID;
	//! Typedef to handle context IDs
	typedef int CONTEXTID;
	//! Typedef for graphic resource managers
	typedef ResourceManager<ID,CONTEXTID> GraphicResourceManager;

private:
	//! The graphic resource manager class is friend of the graphic resource class because it must be able to access its ID and context
	friend class GraphicResourceManager;

public:
	GraphicResource();
	virtual ~GraphicResource();

protected:
	//! Destroy the resource for good
	virtual void destroy_resource() const = 0;

	//! Accessor to the context in which the resource is available
	virtual CONTEXTID context() const = 0;

	//! Accessor to the reference of the resource
	virtual GraphicResource::ID reference() const = 0;
};



//========================================================


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
